import http from '@/utils/http'

const passport = {
  verifyToken: () => http.get('/user/passport/verify_token'),
  login: (values) => http.post('/user/passport/login', values),
  register: (values) => http.post('/user/passport/register', values),
  forget: (type, values) => http.post('/user/passport/forget', Object.assign({ type }, values)),
}

const profile = {
  info: () => http.get('/user/profile/info'),
  update: (values) => http.put('/user/profile/update', values),
  unbind: (type, account, captcha) => http.post('/user/profile/unbind', { type, account, captcha }),
  bind: (type, account, captcha) => http.post('/user/profile/bind', { type, account, captcha }),
}

const signIn = {
  tick: () => http.post('/user/sign_in/tick'),
  monthData: (year, month) => http.get(`/user/sign_in/month?year=${year}&month=${month}`),
}

const score = {
  logs: (page = 1, pageSize = 10) => http.get(`/user/score/logs?page=${page}&pageSize=${pageSize}`),
}

const invite = {
  logs: (page = 1, pageSize = 10) =>
    http.get(`/user/invite/logs?page=${page}&pageSize=${pageSize}`),
}

const captcha = {
  sendEms: (email, event) => http.post('/user/captcha/ems', { email, event }),
  sendSms: (mobile, event) => http.post('/user/captcha/sms', { mobile, event }),
}

export default { passport, profile, signIn, score, invite, captcha }
